// default package
// Generated Jul 31, 2013 2:03:33 PM by Hibernate Tools 3.4.0.CR1
package org.akaza.openclinica.domain.datamap;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.akaza.openclinica.domain.DataMapDomainObject;
import org.akaza.openclinica.domain.Status;
import org.akaza.openclinica.domain.user.UserAccount;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;

/**
 * ItemData generated by hbm2java
 */
@Entity
@Table(name = "item_data")
@GenericGenerator(name = "id-generator", strategy = "native", parameters = { @Parameter(name = "sequence", value = "event_definition_crf_event_definition_crf_id_seq") })
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)

public class ItemData  extends DataMapDomainObject {

	private int itemDataId;
	private UserAccount userAccount;
	private EventCrf eventCrf;
	private Item item;
	private Status status;
	private String value;
	private Date dateCreated;
	private Date dateUpdated;
	private Integer updateId;
	private Integer ordinal;
	private List<DnItemDataMap> dnItemDataMaps;

	public ItemData() {
	}

	public ItemData(int itemDataId, Item item) {
		this.itemDataId = itemDataId;
		this.item = item;
	}

	public ItemData(int itemDataId, UserAccount userAccount, EventCrf eventCrf,
			Item item, Status status, String value, Date dateCreated,
			Date dateUpdated, Integer updateId, Integer ordinal,
			 List<DnItemDataMap> dnItemDataMaps) {
		this.itemDataId = itemDataId;
		this.userAccount = userAccount;
		this.eventCrf = eventCrf;
		this.item = item;
		this.status = status;
		this.value = value;
		this.dateCreated = dateCreated;
		this.dateUpdated = dateUpdated;
		this.updateId = updateId;
		this.ordinal = ordinal;
		
		this.dnItemDataMaps = dnItemDataMaps;
	}

	@Id
	@Column(name = "item_data_id", unique = true, nullable = false)
	@GeneratedValue(generator = "id-generator")
	public int getItemDataId() {
		return this.itemDataId;
	}

	public void setItemDataId(int itemDataId) {
		this.itemDataId = itemDataId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "owner_id")
	public UserAccount getUserAccount() {
		return this.userAccount;
	}

	public void setUserAccount(UserAccount userAccount) {
		this.userAccount = userAccount;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "event_crf_id")
	public EventCrf getEventCrf() {
		return this.eventCrf;
	}

	public void setEventCrf(EventCrf eventCrf) {
		this.eventCrf = eventCrf;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "item_id", nullable = false)
	public Item getItem() {
		return this.item;
	}

	public void setItem(Item item) {
		this.item = item;
	}

	@Type(type = "status")
    @Column(name = "status_id")
    public Status getStatus() {
        if (status != null) {
            return status;
        } else
            return Status.AVAILABLE;
    }

	public void setStatus(Status status) {
		this.status = status;
	}

	@Column(name = "value", length = 4000)
	public String getValue() {
		return this.value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "date_created", length = 4)
	public Date getDateCreated() {
		return this.dateCreated;
	}

	public void setDateCreated(Date dateCreated) {
		this.dateCreated = dateCreated;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "date_updated", length = 4)
	public Date getDateUpdated() {
		return this.dateUpdated;
	}

	public void setDateUpdated(Date dateUpdated) {
		this.dateUpdated = dateUpdated;
	}

	@Column(name = "update_id")
	public Integer getUpdateId() {
		return this.updateId;
	}

	public void setUpdateId(Integer updateId) {
		this.updateId = updateId;
	}

	@Column(name = "ordinal")
	public Integer getOrdinal() {
		return this.ordinal;
	}

	public void setOrdinal(Integer ordinal) {
		this.ordinal = ordinal;
	}

	
	@OneToMany(fetch = FetchType.LAZY,cascade = {CascadeType.ALL}, mappedBy = "itemData")
	@OrderBy("discrepancyNote")
	public List<DnItemDataMap> getDnItemDataMaps() {
		return this.dnItemDataMaps;
	}

	public void setDnItemDataMaps(List<DnItemDataMap> dnItemDataMaps) {
		this.dnItemDataMaps = dnItemDataMaps;
	}



}
